<template>
    <div class="app-container">
        <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
            <el-form-item label="月份" prop="yearMonth">
                <el-select v-model="queryParams.yearMonth" placeholder="请选择月份">
                    <el-option v-for="item in yearMonthList" :label="item" :key="item" :value="item" />
                </el-select>
            </el-form-item>
            <!-- <el-form-item label="处置公司" prop="handleCompanyKey">
                <el-select v-model="queryParams.handleCompanyKey" placeholder="请选择处置公司名称" clearable size="small">
                    <el-option v-for="dict in handleCompanyKeyOptions" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue" />
                </el-select>
            </el-form-item> -->
            <!-- <el-form-item label="出厂日期">
                <el-date-picker v-model="daterangeOutFactoryDate" size="small" style="width: 240px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
            </el-form-item> -->
            <el-form-item>
                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
            </el-form-item>
        </el-form>

        <el-row :gutter="10" class="mb8">
            <el-col :span="1.5">
                <el-button type="warning" plain icon="el-icon-download" size="mini" :loading="exportLoading" @click="handleExport" v-hasPermi="['business:outFactory:export']">导出</el-button>
            </el-col>
            <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
        </el-row>

        <el-table v-loading="loading" :data="outFactoryList">
            <!-- 日期	放行证号	处置公司	危险废物名称	出库数量（吨）	毛重（吨）	净重（吨） 转移联单号 -->
            <el-table-column label="日期" align="center" prop="reportDate" width="120" />
            <el-table-column label="放行证号" align="center" prop="leaveNo" width="120" />
            <el-table-column label="处置公司" align="center" prop="handleCompany" width="150" />
            <el-table-column label="危废名称" align="center" prop="wasteName" min-width="180" />
            <el-table-column label="出厂重量" align="center" prop="outWarehouseWeight" width="100" />
            <el-table-column label="毛重" align="center" prop="totalWeight" width="100" />
            <el-table-column label="净重" align="center" prop="netWeight" width="100" />
            <el-table-column label="转移联单号" align="center" prop="transferNumber" width="150" />
        </el-table>

        <!-- <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" /> -->

    </div>
</template>

<script>
import { outFactoryReport, exportOutFactoryReport, yearMonthList } from "@/api/business/report.js";


export default {
    name: "OutFactoryReport",
    components: {
    },
    data() {
        return {
            //按钮loading
            buttonLoading: false,
            // 遮罩层
            loading: true,
            // 导出遮罩层
            exportLoading: false,
            // 选中数组
            ids: [],
            // 非单个禁用
            single: true,
            // 非多个禁用
            multiple: true,
            // 显示搜索条件
            showSearch: true,
            // 总条数
            total: 0,
            // 委外出厂表格数据
            outFactoryList: [],
            // 出厂日期范围
            daterangeOutFactoryDate: [],
            // 查询参数
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                outFactoryDate: this.parseTime(new Date()),
                yearMonth: this.parseTime(new Date(),  '{y}-{m}')
            },
            yearMonthList: [],
        };
    },
    created() {
        this.getList();
        this.getYearMonthList();
    },
    methods: {
        /** 查询委外出厂列表 */
        getList() {
            this.loading = true;
            this.queryParams.params = {};
            // if (null != this.daterangeOutFactoryDate && '' != this.daterangeOutFactoryDate) {
            //     this.queryParams.params["beginOutFactoryDate"] = this.daterangeOutFactoryDate[0];
            //     this.queryParams.params["endOutFactoryDate"] = this.daterangeOutFactoryDate[1];
            // }
            outFactoryReport(this.queryParams).then(response => {
                this.outFactoryList = response;
                this.loading = false;
            });
        },

        /** 获取年月列表 */
        getYearMonthList() {
            yearMonthList().then((response) => {
                this.yearMonthList = response;
            });
        },
        /** 搜索按钮操作 */
        handleQuery() {
            this.queryParams.pageNum = 1;
            this.getList();
        },
        /** 重置按钮操作 */
        resetQuery() {
            this.daterangeOutFactoryDate = [];
            this.resetForm("queryForm");
            this.queryParams.yearMonth = this.parseTime(new Date(),  '{y}-{m}');
            this.handleQuery();
        },

        /** 导出按钮操作 */
        handleExport() {
            const queryParams = this.queryParams;
            this.$confirm('是否确认导出?', "警告", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning"
            }).then(() => {
                this.exportLoading = true;
                return exportOutFactoryReport(queryParams);
            }).then(response => {
                this.download(response.msg);
                this.exportLoading = false;
            }).catch(() => { });
        },
    }
};
</script>